using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class CustomerAttributeValueMap : EntityTypeConfiguration<CustomerAttributeValue>
    {
        public CustomerAttributeValueMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(400);

            // Table & Column Mappings
            this.ToTable("CustomerAttributeValue");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CustomerAttributeId).HasColumnName("CustomerAttributeId");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.IsPreSelected).HasColumnName("IsPreSelected");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");

            // Relationships
            this.HasRequired(t => t.CustomerAttribute)
                .WithMany(t => t.CustomerAttributeValues)
                .HasForeignKey(d => d.CustomerAttributeId);

        }
    }
}
